//cardtest2 -- embargo
//Getting seg fault ??
#include "dominion.h"
#include "dominion_helpers.h"
#include "rngs.h"
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <assert.h>

int main(int argc, char const *argv[])
{
	//coins, supplyCount, embargoTokens
	struct gameState state;
	int i, j, checkcoins, checkcount;
	int player;
	int card = 22;
	int handPos;
	int choice1;
	int r;
	int *bonus = 0;

	//card choice is there
	for( i = 0; i < 2000; i++){
		for (j = 0; j < sizeof(struct gameState); j++) {
			((char*)&state)[j] = floor(Random() * 256);
		}
		state.coins = rand() % 20;
		checkcoins = state.coins;
		player = rand() % 5;
		choice1 = rand() % 27;
		state.supplyCount[choice1] += 1;
		state.handCount[player] = rand() % MAX_HAND;
		checkcount = state.handCount[player];
		state.embargoTokens[choice1] = 0;
		for(j = 0; j < state.handCount[player]; j++){
			state.hand[player][j] = rand() % 27;
		}
		handPos = rand() % state.handCount[player];
		state.hand[player][handPos] = card;
		r = cardEffect(card, choice1, 0, 0, &state, handPos, &bonus);
		assert(r == 0);
		if(checkcoins + 2 == state.coins){
			if(checkcount - 1 == state.handCount[player]){
				if(state.embargoTokens[choice1] == 1){
					printf("Pass\n");
				} else {
					printf("Fail: embargo tokens\n");
				}
			} else{
				printf("Fail: incorrect hand count\n");
			}
		} else {
			printf("Fail: incorrect coins\n");
		}
	}

	

	//card isn't there
	for (j = 0; j < sizeof(struct gameState); j++) {
			((char*)&state)[i] = floor(Random() * 256);
		}
		state.coins = rand() % 20;
		checkcoins = state.coins;
		player = rand() % 5;
		choice1 = rand() % 27;
		state.supplyCount[choice1] == -1;
		state.handCount[player] = rand() % MAX_HAND;
		checkcount = state.handCount[player];
		for(j = 0; j < state.handCount[player]; j++){
			state.hand[player][j] = rand() % 27;
		}
		handPos = rand() % state.handCount[player];
		state.hand[player][handPos] = card;
		r = cardEffect(card, choice1, 0, 0, &state, handPos, &bonus);
		assert(r == -1);
		printf("Pass: choice not there\n");
		
	return 0;
}